package java04;
public class Hotel {
    Room[][] rooms;

    public Hotel() {
        rooms = new Room[3][10];
        for(int i = 0; i < rooms.length; i++){
            for(int j = 0; j < rooms[i].length; j++){
                if(i == 0){
                    rooms[i][j] = new Room((i+1)*100+j+1,"单人间",true);
                }else if(i == 1){
                    rooms[i][j] = new Room((i+1)*100+j+1,"标准间",true);
                }else if(i == 2){
                    rooms[i][j] = new Room((i+1)*100+j+1,"总统套房",true);
                }
            }
        }
    }
    //打印房间状态
    public void print(){
        for(int i = 0; i < rooms.length; i++){
            for(int j = 0; j < rooms[i].length; j++) {
                Room room =rooms[i][j];
                System.out.print(room);
                 }
            System.out.println();
            }
    }
    //订房方法
    public void order(int roomNo){
        Room room = rooms[roomNo / 100 - 1][roomNo % 100 - 1];
        if(room.getStatus() == false){
            System.out.println("该房间已被占用，请重新选择！");
            return;
        }
        room.setStatus(false);
        System.out.println(roomNo + "订房成功！");
    }
    //退房方法
    public void exit(int roomNo){
        Room room = rooms[roomNo / 100 - 1][roomNo % 100 - 1];
        room.setStatus(true);
        System.out.println(roomNo + "退房成功！");
    }
}
